package com.king.pattem.future.jdk;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

/**
 * @author taomk
 * @version 1.0
 * @since 15-2-2 下午9:32
 */
public class Main {

	public static void main(String [] args) throws ExecutionException, InterruptedException {
		// 构造FutureTask
		FutureTask<String> future = new FutureTask<>(new RealData("a"));
		ExecutorService executor = Executors.newFixedThreadPool(1);
		executor.submit(future);
		System.out.println("请求完毕");
		try {
			Thread.sleep(2000);
		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println("数据 = " + future.get());
	}
}
